package com.common.utils;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;

import java.io.File;
import java.net.URI;

public class GlideUtil {

    public static void loadImageUrl(Context context, String url, ImageView imageView) {
        LogUtil.e("loadImageUrl     " + url);
        RequestOptions options = new RequestOptions();
        options.skipMemoryCache(true)
                .diskCacheStrategy(DiskCacheStrategy.RESOURCE);
        Glide.with(context).load(url).apply(options).into(imageView);
    }

    public static void loadImageUri(Context context, URI uri, ImageView imageView) {
        RequestOptions options = new RequestOptions();
        options.skipMemoryCache(true)
                .diskCacheStrategy(DiskCacheStrategy.RESOURCE);
        Glide.with(context).load(uri).apply(options).into(imageView);
    }

    public static void loadImageFile(Context context, File file, ImageView imageView) {
        RequestOptions options = new RequestOptions();
        options.skipMemoryCache(true)
                .diskCacheStrategy(DiskCacheStrategy.RESOURCE);
        Glide.with(context).load(file).apply(options).into(imageView);
    }
}
